package com.quan.server;

import com.mark.util.JsonUtil;
import com.mark.util.wxmp.WeixinMPClient;
import com.mark.util.wxmp.mpbeans.ClickButton;
import com.mark.util.wxmp.mpbeans.Menu;
import com.mark.util.wxmp.mpbeans.ViewButton;
import com.quan.server.client.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class UpdateMenu {
    private static Logger logger = LoggerFactory.getLogger(UpdateMenu.class);

    public static void main(String[] args) {
        WeixinMPClient weixinMPClient = new WeixinMPClient();
        String accessToken = RestClient.getConfigFromGamma().get(Const.CONFIG_KEY_ACCESS_TOKEN).toString();
        logger.info("accessToken:" + accessToken);
        Menu menu = getMenu();
        weixinMPClient.registerMenu(accessToken, menu);
    }

    /**
     * 菜单
     * 提现 | 成为代理
     */
    public static Menu getMenu() {
        String domainName = "http://youhuiquan.duapp.com";

        ViewButton buttonWithdraw = new ViewButton();
        buttonWithdraw.setName("提现申请");
        buttonWithdraw.setUrl(domainName + "/weixinmp/PageHome");

        Menu menu = new Menu();
        menu.getButton().add(buttonWithdraw);
        logger.info(JsonUtil.bean2Json(menu));

        return menu;
    }

    /**
     * 菜单
     * 提现 | 成为代理
     */
    public static Menu getMenuPatientOnly() {
        String domainName = "https://youhuiquan.duapp.com";

        ViewButton buttonWithdraw = new ViewButton();
        buttonWithdraw.setName("提现申请");
        buttonWithdraw.setUrl("http://www.sina.com.cn");
//        buttonPatientPostMeeting.setUrl(domainName + "/weixinmp/tabDoctorList");

        ViewButton buttonBeingProxy = new ViewButton();
        buttonBeingProxy.setName("成为代理");
        buttonBeingProxy.setUrl("http://www.163.com");
//        buttonPatientMyMeetingList.setUrl(domainName + "/weixinmp/tabMeetingList");

        ViewButton buttonPatientMy = new ViewButton();
        buttonPatientMy.setName("个人信息");
        buttonPatientMy.setUrl(domainName + "/weixinmp/tabMy");

//        ClickButton buttonPatient = new ClickButton();
//        buttonPatient.setName("患者");
//        buttonPatient.setKey("p00");

        Menu menu = new Menu();
        menu.getButton().add(buttonWithdraw);
        menu.getButton().add(buttonBeingProxy);
//        menu.getButton().add(buttonPatientMy);

        logger.info(JsonUtil.bean2Json(menu));

        return menu;
    }

    /**
     * 按照角色分类菜单
     */
    public Menu getMenuRole() {

        String domainName = "http://chaojihaoyi.duapp.com";
        /**
         * Patient
         */
        ViewButton buttonPatientPostMeeting = new ViewButton();
        buttonPatientPostMeeting.setName("会诊申请");
        buttonPatientPostMeeting.setUrl(domainName + "/patientHome/tabDoctorList");

        ViewButton buttonPatientMyMeetingList = new ViewButton();
        buttonPatientMyMeetingList.setName("我的会诊");
        buttonPatientMyMeetingList.setUrl(domainName + "/patientHome/tabMeetingList");

        ViewButton buttonPatientMy = new ViewButton();
        buttonPatientMy.setName("个人信息");
        buttonPatientMy.setUrl(domainName + "/patientHome/tabMy");

        ClickButton buttonPatient = new ClickButton();
        buttonPatient.setName("患者");
        buttonPatient.setKey("p00");

        buttonPatient.getSub_button().add(buttonPatientPostMeeting);
        buttonPatient.getSub_button().add(buttonPatientMyMeetingList);
        buttonPatient.getSub_button().add(buttonPatientMy);

        /**
         * Local Doctor
         */
        ViewButton buttonLocalDoctorMyMeetingList = new ViewButton();
        buttonLocalDoctorMyMeetingList.setName("我的会诊");
        buttonLocalDoctorMyMeetingList.setUrl(domainName + "/localDoctorHome/tabMeetingList");

        ViewButton buttonLocalDoctorMy = new ViewButton();
        buttonLocalDoctorMy.setName("个人信息");
        buttonLocalDoctorMy.setUrl(domainName + "/localDoctorHome/tabMy");

        ClickButton buttonLocalDoctor = new ClickButton();
        buttonLocalDoctor.setName("本地医生");
        buttonLocalDoctor.setKey("localDoctor");

        buttonLocalDoctor.getSub_button().add(buttonLocalDoctorMyMeetingList);
        buttonLocalDoctor.getSub_button().add(buttonLocalDoctorMy);

        /**
         * Remote Doctor
         */
        ViewButton buttonP = new ViewButton();
        buttonP.setName("demo");
        buttonP.setUrl(domainName + "/p");

        ViewButton buttonRemoteDoctorMyMeetingList = new ViewButton();
        buttonRemoteDoctorMyMeetingList.setName("我的会诊");
        buttonRemoteDoctorMyMeetingList.setUrl(domainName + "/remoteDoctorHome/tabMeetingList");

        ViewButton buttonRemoteDoctorMy = new ViewButton();
        buttonRemoteDoctorMy.setName("个人信息");
        buttonRemoteDoctorMy.setUrl(domainName + "/remoteDoctorHome/tabMy");

        ClickButton buttonRemoteDoctor = new ClickButton();
        buttonRemoteDoctor.setName("远程专家");
        buttonRemoteDoctor.setKey("remoteDoctor");

        buttonRemoteDoctor.getSub_button().add(buttonRemoteDoctorMyMeetingList);
        buttonRemoteDoctor.getSub_button().add(buttonRemoteDoctorMy);

        Menu menu = new Menu();
        menu.getButton().add(buttonPatient);
        menu.getButton().add(buttonLocalDoctor);
        menu.getButton().add(buttonRemoteDoctor);

        logger.info(JsonUtil.bean2Json(menu));

        return menu;
    }
}
